<template>
    <view class='my-unit'>
		<!-- <view class="unit-head">
			<text>求购编号：12346579812</text><text class="fr color-999">正在报价</text>
		</view> -->
		<view class="unit-body" :style='"background-image: url("+staticImgUrl+"preferentialleft.png);"'>
			<!-- <image src="../../../static/images/preferentialleft.png" style="width: 30%;height: 120px;"></image> -->
			<view style="width: 25%;color: white;padding-top: 15px;padding-bottom: 10px;text-align: center;">
				<view style="font-weight: 700;font-size: 14px;">{{couponParse1}}</view>
				<view >{{info.couponName}}</view>
				<view style="margin-top: 10px;">{{isAutoUse1}}</view>
			</view>
			<view  style="width: 70%;padding-left: 5px;">
				<view style="display:flex;align-items: center;">
					<view style="width: 75%;">
						<view ><text style="font-weight: 700;font-size: 12px;">{{couponContext1}}</text><text style="color: #E99336;margin-left: 10px;">{{info.carNumber}}</text></view>
						<view><text>领取时间:</text><uni-dateformat :date="info.createTime"></uni-dateformat></view>
						<view><text>有效时间:</text><uni-dateformat :date="info.expirationTime"></uni-dateformat></view>
					</view>
					<view style="width: 25%;padding-top: 20px;" v-if="initIndex == '0'">
						<button style="font-size: 12px;padding: 0;color: #5893F3;border-radius: 25px;border: 1.5px solid #5893F3;">去使用</button>
					</view>
				</view>
				<view >
					<image :src='staticImgUrl+"gps.png"' style="width:12px;height: 15px;margin-right: 5px;margin-top: 5px;float: left;"></image>
					<text>{{info.garageName}}</text>
					<image :src='staticImgUrl+"arrow-drop-right-line.png"' style="width:12px;height: 15px;margin-right: 5px;float: right;margin-top: 8px;"></image>
					
				</view>
			</view>
			<!-- <text v-for="(item,index) in unitModel1" :key="index" >{{item.label}}：<text v-if="item.isMoney" :class="item.class">￥ </text><text :class="item.class">暂无</text><text v-if="item.isMoney" :class="item.class"> 元</text></text> -->
		</view>
		<!-- <view class="unit-foot">
			<text class="color-999">20190212</text>
			<button class="fr btn" type="warn" @click="doDel">删除求购</button>
		</view> -->
    </view>
</template>
	
<script>
    export default{
		props: {
			info: {
				type: Object,
			},
			initIndex:{
				type: Number
			}
			},
        data() {
            return {
				unitModel1:[
				]
            }
        },
        methods:{
			doDel(){
				this.$store.commit("switch_loading")
			},
			couponContext(coupon){
				switch (coupon.couponType) {
					case 0:return "全免";break;
					case 1:return "减免金额"+this.couponParse(coupon,true);break;
					case 2:return "减免时长"+this.couponParse(coupon,true);break;
					case 3:return "车费打折"+this.couponParse(coupon,true);break;
					case 4:return "访客券减免"+this.couponParse(coupon,true);break;
					case 5:return "减免时长"+this.couponParse(coupon,true);break;
				}
			},
			couponParse(coupon,numHide){
				
				if(coupon.couponType==0){//全免
					return "全免";
				}
				if(coupon.couponType==1){//减免金额
					return (coupon.couponNumber?"0":coupon.couponNumber)+"元"+(numHide?"":"X"+coupon.number);
				}
				if(coupon.couponType==2){//免时长
					return (coupon.couponNumber?"0":coupon.couponNumber)+"小时"+(numHide?"":"X"+coupon.number);
				}
				if(coupon.couponType==3){//打折
					return (coupon.couponNumber?"0":coupon.couponNumber)+"折"+(numHide?"":"X"+coupon.number);
				}
				if(coupon.couponType==4){//访客券
					return (coupon.couponNumber?"0":coupon.couponNumber)+"时"+(numHide?"":"X"+coupon.number);
				}
				if(coupon.couponType==5){//储时券
					return (coupon.couponNumber?"0":coupon.couponNumber)+"时";
				}
			},
			
			isAutoUse(coupon){
				switch (coupon.couponType) {
					case 2:return "自动使用";break;
					case 4:return "自动使用";break;
					case 5:return "自动使用";break;
				}
				return "";
			},
        },
		
		computed:{
			staticImgUrl() {
				return this.$store.state.staticImgUrl
				
			},
			couponParse1(){
				return this.couponParse(this.info);
			},
			isAutoUse1(){
				return this.isAutoUse(this.info);
			},
			couponContext1(){
				return this.couponContext(this.info);
			},
		},
		created() {

		},
    }
</script>
<style lang='scss'>
    .my-unit{
		margin: 20upx 0;
		background-color: #ffffff;
		font-size: 28upx;
		transform: all 1s;
		
		.unit-head{
			padding: 20upx;
			height: 80upx;
			box-sizing: border-box;
			border-bottom: 2upx solid #f5f5f5;
		}
		.unit-body{
			/* padding: 20upx; */
			display: flex;
			flex-wrap: wrap;
			
			background-size: 100px 100%; //重点设置
			background-repeat: no-repeat;
			text{
				width: 50%;
				font-size: 28upx;
				line-height: 55upx;
			}
		}
		.unit-foot{
			height: 88upx;
			padding: 0 20upx;
			border-top: 2upx solid #f5f5f5;
			border-bottom: none;
			line-height: 88upx;
			
			.btn{
				height: 60upx;
				font-size: 28upx;
				line-height: 60upx;
				margin: 14upx 0;
			}
		}
	}
</style>